home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 1.toast / Sample Code / Devices and Hardware / Drivers / Load PCI Driver / MoreFiles / FileCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  8.5 KB  |  222 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        FileCopy.h
  3.     
  4.     Description:A robust, general purpose file copy routine.
  5.  
  6.     Author:        JL
  7.  
  8.     Copyright:     Copyright: © 1992-1999 by Apple Computer, Inc.
  9.                 all rights reserved.
  10.     
  11.     Disclaimer:    You may incorporate this sample code into your applications without
  12.                 restriction, though the sample code has been provided "AS IS" and the
  13.                 responsibility for its operation is 100% yours.  However, what you are
  14.                 not permitted to do is to redistribute the source as "DSC Sample Code"
  15.                 after having made changes. If you're going to re-distribute the source,
  16.                 we require that you make it clear in the source that the code was
  17.                 descended from Apple Sample Code, but that you've made changes.
  18.     
  19.     Change History (most recent first):
  20.                 6/25/99    Updated for Metrowerks Codewarror Pro 2.1(KG)
  21.  
  22. */
  23. #ifndef __FILECOPY__
  24. #define __FILECOPY__
  25.  
  26. #include <Types.h>
  27. #include <Files.h>
  28.  
  29. #include "Optimization.h"
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. /*****************************************************************************/
  36.  
  37. pascal    OSErr    FileCopy(short srcVRefNum,
  38.                          long srcDirID,
  39.                          ConstStr255Param srcName,
  40.                          short dstVRefNum,
  41.                          long dstDirID,
  42.                          ConstStr255Param dstPathname,
  43.                          ConstStr255Param copyName,
  44.                          void *copyBufferPtr,
  45.                          long copyBufferSize,
  46.                          Boolean preflight);
  47. /*    ¶ Duplicate a file and optionally rename it.
  48.     The FileCopy function duplicates a file and optionally renames it.
  49.     Since the PBHCopyFile routine is only available on some
  50.     AFP server volumes under specific conditions, this routine
  51.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  52.     does.  The srcVRefNum, srcDirID and srcName are used to
  53.     determine the location of the file to copy.  The dstVRefNum
  54.     dstDirID and dstPathname are used to determine the location of
  55.     the destination directory.  If copyName <> NIL, then it points
  56.     to the name of the new file.  If copyBufferPtr <> NIL, it
  57.     points to a buffer of copyBufferSize that is used to copy
  58.     the file's data.  The larger the supplied buffer, the
  59.     faster the copy.  If copyBufferPtr = NIL, then this routine
  60.     allocates a buffer in the application heap. If you pass a
  61.     copy buffer to this routine, make its size a multiple of 512
  62.     ($200) bytes for optimum performance.
  63.     
  64.     srcVRefNum        input:    Source volume specification.
  65.     srcDirID        input:    Source directory ID.
  66.     srcName            input:    Source file name.
  67.     dstVRefNum        input:    Destination volume specification.
  68.     dstDirID        input:    Destination directory ID.
  69.     dstPathname        input:    Pointer to destination directory name, or
  70.                             nil when dstDirID specifies a directory.
  71.     copyName        input:    Points to the new file name if the file is
  72.                             to be renamed or nil if the file isn't to
  73.                             be renamed.
  74.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  75.                             is used the i/o buffer for the copy or
  76.                             nil if you want FileCopy to allocate its
  77.                             own buffer in the application heap.
  78.     copyBufferSize    input:    The size of the buffer pointed to
  79.                             by copyBufferPtr.
  80.     preflight        input:    If true, FileCopy makes sure there are enough
  81.                             allocation blocks on the destination volume to
  82.                             hold both the data and resource forks before
  83.                             starting the copy.
  84.     
  85.     Result Codes
  86.         noErr                0        No error
  87.         readErr                –19        Driver does not respond to read requests
  88.         writErr                –20        Driver does not respond to write requests
  89.         badUnitErr            –21        Driver reference number does not
  90.                                     match unit table
  91.         unitEmptyErr        –22        Driver reference number specifies a
  92.                                     nil handle in unit table
  93.         abortErr            –27        Request aborted by KillIO
  94.         notOpenErr            –28        Driver not open
  95.         dskFulErr            -34        Destination volume is full
  96.         nsvErr                -35        No such volume
  97.         ioErr                -36        I/O error
  98.         bdNamErr            -37        Bad filename
  99.         tmfoErr                -42        Too many files open
  100.         fnfErr                -43        Source file not found, or destination
  101.                                     directory does not exist
  102.         wPrErr                -44        Volume locked by hardware
  103.         fLckdErr            -45        File is locked
  104.         vLckdErr             -46        Destination volume is read-only
  105.         fBsyErr                 -47        The source or destination file could
  106.                                     not be opened with the correct access
  107.                                     modes
  108.         dupFNErr            -48        Destination file already exists
  109.         opWrErr                -49        File already open for writing
  110.         paramErr            -50        No default volume or function not
  111.                                     supported by volume
  112.         permErr                 -54        File is already open and cannot be opened using specified deny modes
  113.         memFullErr            -108    Copy buffer could not be allocated
  114.         dirNFErr            -120    Directory not found or incomplete pathname
  115.         wrgVolTypErr        -123    Function not supported by volume
  116.         afpAccessDenied        -5000    User does not have the correct access
  117.         afpDenyConflict        -5006    The source or destination file could
  118.                                     not be opened with the correct access
  119.                                     modes
  120.         afpObjectTypeErr    -5025    Source is a directory, directory not found
  121.                                     or incomplete pathname
  122.     
  123.     __________
  124.     
  125.     Also see:    FSpFileCopy, DirectoryCopy, FSpDirectoryCopy
  126. */
  127.  
  128. /*****************************************************************************/
  129.  
  130. pascal    OSErr    FSpFileCopy(const FSSpec *srcSpec,
  131.                             const FSSpec *dstSpec,
  132.                             ConstStr255Param copyName,
  133.                             void *copyBufferPtr,
  134.                             long copyBufferSize,
  135.                             Boolean preflight);
  136. /*    ¶ Duplicate a file and optionally rename it.
  137.     The FSpFileCopy function duplicates a file and optionally renames it.
  138.     Since the PBHCopyFile routine is only available on some
  139.     AFP server volumes under specific conditions, this routine
  140.     either uses PBHCopyFile, or does all of the work PBHCopyFile
  141.     does.  The srcSpec is used to
  142.     determine the location of the file to copy.  The dstSpec is
  143.     used to determine the location of the
  144.     destination directory.  If copyName <> NIL, then it points
  145.     to the name of the new file.  If copyBufferPtr <> NIL, it
  146.     points to a buffer of copyBufferSize that is used to copy
  147.     the file's data.  The larger the supplied buffer, the
  148.     faster the copy.  If copyBufferPtr = NIL, then this routine
  149.     allocates a buffer in the application heap. If you pass a
  150.     copy buffer to this routine, make its size a multiple of 512
  151.     ($200) bytes for optimum performance.
  152.     
  153.     srcSpec            input:    An FSSpec record specifying the source file.
  154.     dstSpec            input:    An FSSpec record specifying the destination
  155.                             directory.
  156.     copyName        input:    Points to the new file name if the file is
  157.                             to be renamed or nil if the file isn't to
  158.                             be renamed.
  159.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  160.                             is used the i/o buffer for the copy or
  161.                             nil if you want FileCopy to allocate its
  162.                             own buffer in the application heap.
  163.     copyBufferSize    input:    The size of the buffer pointed to
  164.                             by copyBufferPtr.
  165.     preflight        input:    If true, FSpFileCopy makes sure there are
  166.                             enough allocation blocks on the destination
  167.                             volume to hold both the data and resource forks
  168.                             before starting the copy.
  169.     
  170.     Result Codes
  171.         noErr                0        No error
  172.         readErr                –19        Driver does not respond to read requests
  173.         writErr                –20        Driver does not respond to write requests
  174.         badUnitErr            –21        Driver reference number does not
  175.                                     match unit table
  176.         unitEmptyErr        –22        Driver reference number specifies a
  177.                                     nil handle in unit table
  178.         abortErr            –27        Request aborted by KillIO
  179.         notOpenErr            –28        Driver not open
  180.         dskFulErr            -34        Destination volume is full
  181.         nsvErr                -35        No such volume
  182.         ioErr                -36        I/O error
  183.         bdNamErr            -37        Bad filename
  184.         tmfoErr                -42        Too many files open
  185.         fnfErr                -43        Source file not found, or destination
  186.                                     directory does not exist
  187.         wPrErr                -44        Volume locked by hardware
  188.         fLckdErr            -45        File is locked
  189.         vLckdErr             -46        Destination volume is read-only
  190.         fBsyErr                 -47        The source or destination file could
  191.                                     not be opened with the correct access
  192.                                     modes
  193.         dupFNErr            -48        Destination file already exists
  194.         opWrErr                -49        File already open for writing
  195.         paramErr            -50        No default volume or function not
  196.                                     supported by volume
  197.         permErr                 -54        File is already open and cannot be opened using specified deny modes
  198.         memFullErr            -108    Copy buffer could not be allocated
  199.         dirNFErr            -120    Directory not found or incomplete pathname
  200.         wrgVolTypErr        -123    Function not supported by volume
  201.         afpAccessDenied        -5000    User does not have the correct access
  202.         afpDenyConflict        -5006    The source or destination file could
  203.                                     not be opened with the correct access
  204.                                     modes
  205.         afpObjectTypeErr    -5025    Source is a directory, directory not found
  206.                                     or incomplete pathname
  207.     
  208.     __________
  209.     
  210.     Also see:    FileCopy, DirectoryCopy, FSpDirectoryCopy
  211. */
  212.  
  213. /*****************************************************************************/
  214.  
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218.  
  219. #include "OptimizationEnd.h"
  220.  
  221. #endif    /* __FILECOPY__ */
  222.